// careful not to get high! cuz my stuff is dope
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define vb vector<bool>
#define vp vector<pair<int,int>>
#define all(v) (v).begin()+1,(v).end()
#define pi pair<int,int>
#define mpi map<int,int>
#define edl '\n'
#define pyes cout<<"YES\n";
#define pno cout<<"NO\n";
#define pb(x) push_back(x)
#define fr(i,s,e) for(ll i = (ll)s; i < (ll)e; i++)
#define rfr(i,s,e) for(ll i = (ll)e; i >= (ll)s; i--)
#define fa(x,a) for(auto x: a)
#define read(a) for(auto &x: a) cin >> x;
#define put(a) for(auto &x: a) cout << x << " "; cout << nl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define files freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#endif
#define int long long
template <typename C> void UNIQUE(vector<C> &v) { sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
int n;cin>>n;
ll num=232792560;
vector<vp>contri(21,vp(200001,{0,0}));
fr(i,1,21) fr(j,1,200000)contri[i][j].second = j;
fr(i,0,n){
int m,k;cin>>m>>k;
fr(j,1,k+1)contri[j][m].first+=num;
fr(j,k + 1,21)contri[j][m].first+=(num/j)*k;
}
int ans=-1,ind=-1;
fr(i,1,21){
sort(all(contri[i]));
reverse(all(contri[i]));
ll curr=0;
fr(j,1,i+1)curr += contri[i][j].first;
if(curr>=ans){
ans = curr;
ind = i;
}
}
cout<<ind<<"\n";
fr(j,1,ind+1)cout<<contri[ind][j].second<<" ";
cout << "\n";
}
signed main(){
fast;
int tt=1;
while(tt--){
solve();
}
return 0;
}
855A - Tom Riddle's Diary | 1417A - Copy-paste |
1038A - Equality | 1061A - Coins |
1676E - Eating Queries | 1447A - Add Candies |
1721D - Maximum AND | 363C - Fixing Typos |
1401A - Distance and Axis | 658A - Bear and Reverse Radewoosh |
1721E - Prefix Function Queries | 977E - Cyclic Components |
1140D - Minimum Triangulation | 75C - Modified GCD |
1722A - Spell Check | 1722B - Colourblindness |
1722D - Line | 1722C - Word Game |
1722G - Even-Odd XOR | 552E - Vanya and Brackets |
933A - A Twisty Movement | 1722F - L-shapes |
1196B - Odd Sum Segments | 1325D - Ehab the Xorcist |
552B - Vanya and Books | 1722E - Counting Rectangles |
168A - Wizards and Demonstration | 168B - Wizards and Minimal Spell |
7A - Kalevitch and Chess | 912B - New Year's Eve |